home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 January: Mac OS SDK / Dev.CD Jan 99 SDK1.toast / Development Kits / Interfaces&Libraries / Universal / Interfaces / CIncludes / CursorDevices.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-08-17  |  7.9 KB  |  245 lines  |  [TEXT/MPS ]

  1. /*
  2.      File:        CursorDevices.h
  3.  
  4.      Contains:    Cursor Devices (mouse/trackball/etc) Interfaces.
  5.  
  6.      Version:    Technology:    System 7.5
  7.                  Release:    Universal Interfaces 3.2
  8.  
  9.      Copyright:    © 1993-1998 by Apple Computer, Inc., all rights reserved.
  10.  
  11.      Bugs?:        For bug reports, consult the following page on
  12.                  the World Wide Web:
  13.  
  14.                      http://developer.apple.com/bugreporter/
  15.  
  16. */
  17. #ifndef __CURSORDEVICES__
  18. #define __CURSORDEVICES__
  19.  
  20. #ifndef __MACTYPES__
  21. #include <MacTypes.h>
  22. #endif
  23. #ifndef __MIXEDMODE__
  24. #include <MixedMode.h>
  25. #endif
  26.  
  27.  
  28.  
  29. #if PRAGMA_ONCE
  30. #pragma once
  31. #endif
  32.  
  33. #ifdef __cplusplus
  34. extern "C" {
  35. #endif
  36.  
  37. #if PRAGMA_IMPORT
  38. #pragma import on
  39. #endif
  40.  
  41. #if PRAGMA_STRUCT_ALIGN
  42.     #pragma options align=mac68k
  43. #elif PRAGMA_STRUCT_PACKPUSH
  44.     #pragma pack(push, 2)
  45. #elif PRAGMA_STRUCT_PACK
  46.     #pragma pack(2)
  47. #endif
  48.  
  49. /*
  50.                         * * *  I M P O R T A N T  * * * 
  51.  
  52.             You will need CursorDevicesGlue.o to use CDM from PowerPC
  53.  
  54.  
  55.     In order to use the Cursor Devices Manager (CDM) on PowerPC systems, you must 
  56.     link with the file CursorDevicesGlue.o and InterfaceLib 1.1.3.  This is necessary
  57.     because the original MixedMode transition code for CDM in InterfaceLib in ROM
  58.     was wrong.  The code in CursorDevicesGlue.o will check to see if the ROM has
  59.     been fixed and calls through to it if so.  If it detects that the ROM has not
  60.     been fixed, it uses its own implementation of the CDM MixedMode transition 
  61.     routines. 
  62.     
  63. */
  64.  
  65. typedef short                             ButtonOpcode;
  66. /* ButtonOpcodes */
  67.  
  68. enum {
  69.     kButtonNoOp                    = 0,                            /* No action for this button */
  70.     kButtonSingleClick            = 1,                            /* Normal mouse button */
  71.     kButtonDoubleClick            = 2,                            /* Click-release-click when pressed */
  72.     kButtonClickLock            = 3                                /* Click on press, release on next press */
  73. };
  74.  
  75.  
  76. enum {
  77.     kButtonCustom                = 6                                /* Custom behavior, data = CursorDeviceCustomButtonUPP */
  78. };
  79.  
  80. /* Device Classes */
  81.  
  82. enum {
  83.     kDeviceClassAbsolute        = 0,                            /* a flat-response device */
  84.     kDeviceClassMouse            = 1,                            /* mechanical or optical mouse */
  85.     kDeviceClassTrackball        = 2,                            /* trackball */
  86.     kDeviceClassTrackPad        = 3
  87. };
  88.  
  89.  
  90. enum {
  91.     kDeviceClass3D                = 6                                /* a 3D pointing device */
  92. };
  93.  
  94. /* Structures used in Cursor Device Manager calls */
  95.  
  96. struct CursorData {
  97.     struct CursorData *                nextCursorData;                /* next in global list */
  98.     Ptr                             displayInfo;                /* unused (reserved for future) */
  99.     Fixed                             whereX;                        /* horizontal position */
  100.     Fixed                             whereY;                        /* vertical position */
  101.     Point                             where;                        /* the pixel position */
  102.     Boolean                         isAbs;                        /* has been stuffed with absolute coords */
  103.     UInt8                             buttonCount;                /* number of buttons currently pressed */
  104.     long                             screenRes;                    /* pixels per inch on the current display */
  105.     short                             privateFields[22];            /* fields use internally by CDM */
  106. };
  107. typedef struct CursorData                CursorData;
  108. typedef CursorData *                    CursorDataPtr;
  109.  
  110. struct CursorDevice {
  111.     struct CursorDevice *            nextCursorDevice;            /* pointer to next record in linked list */
  112.     CursorData *                    whichCursor;                /* pointer to data for target cursor */
  113.     long                             refCon;                        /* application-defined */
  114.     long                             unused;                        /* reserved for future */
  115.     OSType                             devID;                        /* device identifier (from ADB reg 1) */
  116.     Fixed                             resolution;                    /* units/inch (orig. from ADB reg 1) */
  117.     UInt8                             devClass;                    /* device class (from ADB reg 1) */
  118.     UInt8                             cntButtons;                    /* number of buttons (from ADB reg 1) */
  119.     UInt8                             filler1;                    /* reserved for future */
  120.     UInt8                             buttons;                    /* state of all buttons */
  121.     UInt8                             buttonOp[8];                /* action performed per button */
  122.     unsigned long                     buttonTicks[8];                /* ticks when button last went up (for debounce) */
  123.     long                             buttonData[8];                /* data for the button operation */
  124.     unsigned long                     doubleClickTime;            /* device-specific double click speed */
  125.     Fixed                             acceleration;                /* current acceleration */
  126.     short                             privateFields[15];            /* fields used internally to CDM */
  127. };
  128. typedef struct CursorDevice                CursorDevice;
  129. typedef CursorDevice *                    CursorDevicePtr;
  130. /* for use with CursorDeviceButtonOp when opcode = kButtonCustom */
  131. typedef CALLBACK_API( void , CursorDeviceCustomButtonProcPtr )(CursorDevicePtr ourDevice, short button);
  132. /*
  133.     WARNING: CursorDeviceCustomButtonProcPtr uses register based parameters under classic 68k
  134.              and cannot be written in a high-level language without 
  135.              the help of mixed mode or assembly glue.
  136. */
  137. typedef REGISTER_UPP_TYPE(CursorDeviceCustomButtonProcPtr)         CursorDeviceCustomButtonUPP;
  138. enum { uppCursorDeviceCustomButtonProcInfo = 0x000ED802 };         /* register no_return_value Func(4_bytes:A2, 2_bytes:D3) */
  139. #define NewCursorDeviceCustomButtonProc(userRoutine)             (CursorDeviceCustomButtonUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppCursorDeviceCustomButtonProcInfo, GetCurrentArchitecture())
  140. #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  141.     /* CallCursorDeviceCustomButtonProc can't be called from classic 68k without glue code */
  142. #else
  143.     #define CallCursorDeviceCustomButtonProc(userRoutine, ourDevice, button)  CALL_TWO_PARAMETER_UPP((userRoutine), uppCursorDeviceCustomButtonProcInfo, (ourDevice), (button))
  144. #endif
  145. EXTERN_API( OSErr )
  146. CursorDeviceMove                (CursorDevicePtr         ourDevice,
  147.                                  long                     deltaX,
  148.                                  long                     deltaY)                                TWOWORDINLINE(0x7000, 0xAADB);
  149.  
  150. EXTERN_API( OSErr )
  151. CursorDeviceMoveTo                (CursorDevicePtr         ourDevice,
  152.                                  long                     absX,
  153.                                  long                     absY)                                TWOWORDINLINE(0x7001, 0xAADB);
  154.  
  155. EXTERN_API( OSErr )
  156. CursorDeviceFlush                (CursorDevicePtr         ourDevice)                            TWOWORDINLINE(0x7002, 0xAADB);
  157.  
  158. EXTERN_API( OSErr )
  159. CursorDeviceButtons                (CursorDevicePtr         ourDevice,
  160.                                  short                     buttons)                            TWOWORDINLINE(0x7003, 0xAADB);
  161.  
  162. EXTERN_API( OSErr )
  163. CursorDeviceButtonDown            (CursorDevicePtr         ourDevice)                            TWOWORDINLINE(0x7004, 0xAADB);
  164.  
  165. EXTERN_API( OSErr )
  166. CursorDeviceButtonUp            (CursorDevicePtr         ourDevice)                            TWOWORDINLINE(0x7005, 0xAADB);
  167.  
  168. EXTERN_API( OSErr )
  169. CursorDeviceButtonOp            (CursorDevicePtr         ourDevice,
  170.                                  short                     buttonNumber,
  171.                                  ButtonOpcode             opcode,
  172.                                  long                     data)                                TWOWORDINLINE(0x7006, 0xAADB);
  173.  
  174. EXTERN_API( OSErr )
  175. CursorDeviceSetButtons            (CursorDevicePtr         ourDevice,
  176.                                  short                     numberOfButtons)                    TWOWORDINLINE(0x7007, 0xAADB);
  177.  
  178. EXTERN_API( OSErr )
  179. CursorDeviceSetAcceleration        (CursorDevicePtr         ourDevice,
  180.                                  Fixed                     acceleration)                        TWOWORDINLINE(0x7008, 0xAADB);
  181.  
  182. EXTERN_API( OSErr )
  183. CursorDeviceDoubleTime            (CursorDevicePtr         ourDevice,
  184.                                  long                     durationTicks)                        TWOWORDINLINE(0x7009, 0xAADB);
  185.  
  186. EXTERN_API( OSErr )
  187. CursorDeviceUnitsPerInch        (CursorDevicePtr         ourDevice,
  188.                                  Fixed                     resolution)                            TWOWORDINLINE(0x700A, 0xAADB);
  189.  
  190. EXTERN_API( OSErr )
  191. CursorDeviceNextDevice            (CursorDevicePtr *        ourDevice)                            TWOWORDINLINE(0x700B, 0xAADB);
  192.  
  193. EXTERN_API( OSErr )
  194. CursorDeviceNewDevice            (CursorDevicePtr *        ourDevice)                            TWOWORDINLINE(0x700C, 0xAADB);
  195.  
  196. EXTERN_API( OSErr )
  197. CursorDeviceDisposeDevice        (CursorDevicePtr         ourDevice)                            TWOWORDINLINE(0x700D, 0xAADB);
  198.  
  199.  
  200.  
  201.  
  202. /*
  203.                        * * *  W A R N I N G  * * * 
  204.                 
  205.     The routines CrsrDevMoveTo and CrsrDevNextDevice are no longer needed.
  206.     They were added as a work around until the glue code CursorDevicesGlue.o
  207.     was created.  Please use the functions CursorDeviceMoveTo and
  208.     CursorDeviceNextDevice instead.
  209.  
  210. */
  211. #if OLDROUTINENAMES
  212. EXTERN_API( OSErr )
  213. CrsrDevMoveTo                    (CursorDevicePtr         ourDevice,
  214.                                  long                     absX,
  215.                                  long                     absY)                                TWOWORDINLINE(0x7001, 0xAADB);
  216.  
  217. EXTERN_API( OSErr )
  218. CrsrDevNextDevice                (CursorDevicePtr *        ourDevice)                            TWOWORDINLINE(0x700B, 0xAADB);
  219.  
  220. #endif  /* OLDROUTINENAMES */
  221.  
  222.  
  223.  
  224.  
  225. #if PRAGMA_STRUCT_ALIGN
  226.     #pragma options align=reset
  227. #elif PRAGMA_STRUCT_PACKPUSH
  228.     #pragma pack(pop)
  229. #elif PRAGMA_STRUCT_PACK
  230.     #pragma pack()
  231. #endif
  232.  
  233. #ifdef PRAGMA_IMPORT_OFF
  234. #pragma import off
  235. #elif PRAGMA_IMPORT
  236. #pragma import reset
  237. #endif
  238.  
  239. #ifdef __cplusplus
  240. }
  241. #endif
  242.  
  243. #endif /* __CURSORDEVICES__ */
  244.  
  245.